﻿using Liju.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace LiJu.Db
{
    /// <summary>
    /// 螺丝库存变更记录
    /// </summary>
    public class ScrewLogDbHelper
    {
        /// <summary>
        /// 获取螺丝库存变更记录
        /// </summary>
        /// <returns></returns>
        public static List<ScrewLog> GetScrewModelList()
        {
            string strMySql = $"select * from ScrewLog ";
            DataTable dt = DalMySQL.ExecuteDataTable(strMySql);
            return DbExtension.DataTableToList<ScrewLog>(dt);
        }

        /// <summary>
        /// 添加螺丝库存变更记录
        /// </summary>
        /// <returns></returns>
        public static bool ScrewLogAdd(ScrewLog screwLog)
        {
            string strMySql = $"INSERT INTO ScrewLog (ScrewID,LockIO,ChangeType, ChangeNum,ChangePreNum,ChangeLastNum,CreateTime)VALUES({screwLog.ScrewID}, {screwLog.LockIO},{screwLog.ChangeType}, {screwLog.ChangeNum}, {screwLog.ChangePreNum}, {screwLog.ChangeLastNum}, '{screwLog.CreateTime}'); ";
            int result = DalMySQL.ExecuteNonQuery(strMySql);
            return result > 0;
        }


    }
}
